/**
 * 
 */
package com.thor.palmmall.rest.patrol.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.OperateInfoToBeanConverter;
import com.thor.commons.entity.UCN;
import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.patrol.APatrolBill;
import com.thor.palmmall.spi.common.SOperateInfoConverter;
import com.thor.palmmall.spi.device.SDeviceInspect;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class SDeviceInspect4SaveConverter implements Converter<APatrolBill, SDeviceInspect> {

  public static SDeviceInspect4SaveConverter getInstance() {
    if (instance == null)
      instance = new SDeviceInspect4SaveConverter();
    return instance;
  }

  private static SDeviceInspect4SaveConverter instance;

  private SDeviceInspect4SaveConverter() {
  }

  @Override
  public SDeviceInspect convert(APatrolBill source) {
    if (source == null) {
      return null;
    }
    SDeviceInspect target = new SDeviceInspect();
    target.setBpmInstance(source.getBpmInstance());
    target.setBpmMessage(source.getBpmMessage());
    target.setBpmState(source.getBpmState());
    target.setCreateInfo(SOperateInfoConverter.getInstance()
        .convert(OperateInfoToBeanConverter.getInstance().convert(source.getCreateInfo())));
    target.setLastModifyInfo(SOperateInfoConverter.getInstance()
        .convert(OperateInfoToBeanConverter.getInstance().convert(source.getLastModifyInfo())));
    target.setPermGroupId(source.getPermGroupId());
    target.setPermGroupTitle(source.getPermGroupTitle());
    target.setVersion(source.getVersion());
    target.setVersionTime(source.getVersionTime());
    target.setBeginTime(source.getBeginTime());
    target.setEndTime(source.getEndTime());
    target.setBillNumber(source.getBillNumber());
    target.setCategory(UCN.newInstance(source.getCategory()));
    target.setDetails(
        ConverterUtil.convert(source.getDetails(), SDeviceInspectDetailConverter.getInstance()));
    target.setInspector(UCN.newInstance(source.getPatrolman()));
    target.setRemark(source.getRemark());
    target.setStore(UCN.newInstance(source.getStore()));
    target.setInspectTopic(source.getTopic());
    target.setSourceBillNumber(source.getSourceBillNumber());
    target.setSourceUuid(source.getSourceUuid());
    target.setUuid(source.getUuid());
    target.setBizState(source.getBizState());
    target.setSettleNo(source.getSettleNo());
    target.setAbortTime(source.getAbortTime());
    target.setOverTime(source.getOverTime());
    target.setAbortMsg(source.getAbortMsg());
    return target;
  }

}
